package com.ccsu.mymarket.service.Impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ccsu.mymarket.dao.BookDao;
import com.ccsu.mymarket.entity.Book;
import com.ccsu.mymarket.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class BookServiceImpl extends ServiceImpl<BookDao, Book> implements BookService {
    private BookDao bookDao;

    public BookServiceImpl(@Autowired BookDao bookDao) {
        this.bookDao = bookDao;
    }

    @Override
    public List<Book> getPageBooks(Integer pageNum, Integer pageSize) {
        return bookDao.getPageBook(pageNum,pageSize);
    }

    @Override
    public List<Book> searchByKey(Integer pageNum, Integer pageSize, String key) {
        List<Book> bookList=bookDao.searchBookByKey("%"+key+"%",pageNum,pageSize);
        return bookList;
    }

    @Override
    public List<Book> getPageBooksByClass(String catagName,Integer pageNum, Integer pageSize) {
        return bookDao.getPageBooksByClass(pageNum,pageSize,catagName);
    }

    @Override
    public List<Book> getPageBooksByShop(Integer id) {
        return bookDao.getPageBooksByShop(id);
    }

}
